package com.itboye.ihomebank.adapter;

import android.content.Context;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.bean.KaiSuoJiLu;
import com.itboye.ihomebank.bean.KaiSuoJiLuTwo;
import com.itboye.ihomebank.support.commonadapter.MutiplyCommonAdapter;
import com.itboye.ihomebank.support.commonadapter.ViewHolder;
import com.itboye.ihomebank.util.TimesUtils;

import java.util.List;

/**
 * 开锁记录-白马锁
 */

public class KaiSuoJiLuTwoAdapter extends MutiplyCommonAdapter<KaiSuoJiLuTwo.KaiSuoJiLuTwoList> {
    int position;
    List<KaiSuoJiLuTwo.KaiSuoJiLuTwoList> datas;
    public KaiSuoJiLuTwoAdapter(Context context, List<KaiSuoJiLuTwo.KaiSuoJiLuTwoList> datas, int... layoutId) {
        super(context, datas, layoutId);
        this.datas=datas;
    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }

    @Override
    public void getItemPosition(int position) {
        this.position=position;
    }

    @Override
    public void convert(ViewHolder holder, KaiSuoJiLuTwo.KaiSuoJiLuTwoList t, int type, int position) {
        //1-密码,2-IC卡,3-蓝牙,4-临时密码,其他-未知
         String recordtype=t.getType();
        switch (recordtype){
            case "3":
                holder.setText(R.id.jilu_phone, t.getNickname()+"(蓝牙开门)");
                break;
            case "1":
                holder.setText(R.id.jilu_phone, t.getNickname()+"(密码开门:"+t.getTempPass()+")");
                break;
            case "4":
                holder.setText(R.id.jilu_phone, t.getNickname()+"(临时密码开门:"+t.getTempPass()+")");
                break;
            default:
                holder.setText(R.id.jilu_phone, t.getNickname()+"(其他方式开门)");
                break;
        }
        holder.setText(R.id.jilu_name, t.getLock_id());
        String time= TimesUtils.timeStamp2Date(Long.parseLong(t.getOp_time()));
        holder.setText(R.id.jilu_time, time);
        if (t.getResult().equals("1")){
            holder.setText(R.id.jilu_type, "成功");
        }else{
            holder.setText(R.id.jilu_type, "失败");
        }
    }
}
